package com.tgy.cs;

import com.tgy.pojo.Man;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/***
 * @ClassName: SessionDemo2
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 20:41 2021/12/5
 * @version : V1.0
 */
public class SessionDemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html; charset=UTF-8");
        /*得到Session*/
        HttpSession session = req.getSession();
        /*给Session存东西*/
        Object name = session.getAttribute("name");
        resp.getWriter().write(name.toString());
        resp.getWriter().write("对象是："+(Man)session.getAttribute("pojo"));


    }
}
